﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Collections.Generic;
using System.Linq;
using System.Data.Common;
using System.Linq;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using LinqObj;
/// <summary>
/// Summary description for User
/// </summary>
/// 

namespace LinqObj
{
    public partial class Toolbox_User
    {

        private static ToolboxDataContext _context = new ToolboxDataContext();
        private EntityRef<Agent> _Agent;
        [Association(Storage = "_Agent", OtherKey = "user_id",
        ThisKey = "user_id", IsForeignKey = true)]
        public Agent Agent
        {
            get
            {
                return this._Agent.Entity;
            }
        }

        public static Toolbox_User GetUserRef(string userName, string pwd)
        {
            var ret = from _user in _context.GetTable<Toolbox_User>()
                      where _user.password == pwd && _user.user_name == userName
                      select _user;
            return ret.SingleOrDefault();
        }
    }

}